home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / sys / strace.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  3.6 KB  |  99 lines

  1. /* sys/strace.h */
  2.  
  3. /* This file contains routines for tracing system calls and other internal
  4.    phenomenon.
  5.  
  6.    When tracing system calls, try to use the same style throughout:
  7.  
  8.    result = syscall (arg1, arg2, arg3) [optional extra stuff]
  9.  
  10.    If a system call can block (eg: read, write, wait), print another message
  11.    before hanging so the user will know why the program has stopped.
  12.  
  13.    Note: __seterrno will also print a trace message.  Have that printed
  14.    *first*.  This will make it easy to always know what __seterrno is
  15.    refering to.  For the same reason, try not to have __seterrno messages
  16.    printed alone.
  17. */
  18.  
  19. #ifndef _SYS_STRACE_H
  20. #define _SYS_STRACE_H
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. /* Bitmasks of tracing messages to print.  */
  27.  
  28. #ifdef NOSTRACE
  29. #define strace_printf(fmt...) 0
  30. #define strace_printf_wrap(fmt...) 0
  31. #define strace()    0
  32. #define strace_wm(msg...) 0
  33. #else
  34. #define _STRACE_ALL     0x00001 // so behaviour of strace=1 is unchanged
  35. #define _STRACE_FLUSH     0x00002 // flush output buffer after every message
  36. #define _STRACE_INHERIT  0x00004 // children inherit mask from parent
  37. #define _STRACE_UHOH     0x00008 // unusual or weird phenomenon
  38. #define _STRACE_SYSCALL     0x00010 // system calls
  39. #define _STRACE_STARTUP     0x00020 // argc/envp printout at startup
  40. #define _STRACE_DEBUG    0x00040 // info to help debugging
  41. #define _STRACE_PARANOID 0x00080 // paranoid info
  42. #define _STRACE_TERMIOS     0x00100 // info for debugging termios stuff
  43. #define _STRACE_SELECT     0x00200 // info on ugly select internals
  44. #define _STRACE_WM     0x00400 // trace windows messages (enable _strace_wm)
  45. #define _STRACE_SIGP     0x00800 // trace signal and process handling
  46. #define _STRACE_MINIMAL     0x01000 // very minimal strace output
  47. #define _STRACE_EXITDUMP 0x04000 // dump strace cache on exit
  48. #define _STRACE_CACHE     0x08000 // cache strace messages
  49. #define _STRACE_NOMUTEX     0x10000 // don't use mutex for synchronization
  50. #define _STRACE_MALLOC     0x20000 // trace malloc calls
  51. #define _STRACE_THREAD     0x40000 // thread-locking calls
  52.  
  53. /* Return the current strace mask.  */
  54. /* Dump cached strace data, if any */
  55. void strace_dump (void);
  56.  
  57. /* Output message to strace log */
  58. void strace_printf (const char *, ...);
  59. void __system_printf (const char *, ...);
  60. void small_printf (const char *, ...);
  61.  
  62. #define system_printf(fmt, args...) \
  63.     ({\
  64.       __system_printf("%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
  65.     })
  66.  
  67. void _strace_wm (int __message, int __word, int __lon);
  68.  
  69. #define strace() (myself->strace_mask)
  70.  
  71. #define strace_printf_wrap(what, fmt, args...) \
  72.     ({\
  73.     if (strace () & ((_STRACE_ ## what) | 1)) \
  74.       strace_printf("%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
  75.     })
  76. #define strace_printf_wrap1(what, fmt, args...) \
  77.     ({\
  78.     if (strace () & ((_STRACE_ ## what))) \
  79.       strace_printf("%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
  80.     })
  81. #endif /*NOSTRACE*/
  82.  
  83. #define debug_printf(fmt, args...) strace_printf_wrap(DEBUG, fmt , ## args)
  84. #define syscall_printf(fmt, args...) strace_printf_wrap(SYSCALL, fmt , ## args)
  85. #define paranoid_printf(fmt, args...) strace_printf_wrap(PARANOID, fmt , ## args)
  86. #define termios_printf(fmt, args...) strace_printf_wrap(TERMIOS, fmt , ## args)
  87. #define select_printf(fmt, args...) strace_printf_wrap(SELECT, fmt , ## args)
  88. #define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args)
  89. #define sigproc_printf(fmt, args...) strace_printf_wrap(SIGP, fmt , ## args)
  90. #define minimal_printf(fmt, args...) strace_printf_wrap1(MINIMAL, fmt , ## args)
  91. #define malloc_printf(fmt, args...) strace_printf_wrap1(MALLOC, fmt , ## args)
  92. #define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args)
  93.  
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97.  
  98. #endif /* _SYS_STRACE_H */
  99.